//
//  HomeGoodsCardView.swift
//  iFishApp
//
//  Created by Bob on 2022/3/5.
//

import SwiftUI
import SDWebImageSwiftUI

struct HomeGoodsCardView: View {
    var model: GoodsCardModel
    var body: some View {
        VStack {
            WebImage(url: URL(string: model.goodsInfo!.images![0]))
                .resizable()
                .aspectRatio(contentMode: .fit)
                .cornerRadius(10)
            
            VStack(alignment: .leading, spacing: 5) {
                Text(model.goodsInfo!.name!)
                    .font(.system(size: 14, weight: .semibold))
                
                HStack {
                    (
                        Text("￥")
                            .font(.system(size: 10, weight: .semibold))
                        +
                        Text(model.goodsInfo!.priceStr)
                            .font(.system(size: 14, weight: .semibold))
                        
                    )
                    .foregroundColor(Color(hex: 0xFA4B4E))
                    
                    Spacer()
                    Text("\(Int(arc4random_uniform(1000)))人想要")
                        .font(.system(size: 10))
                        .foregroundColor(Color.black.opacity(0.5))
                }
                
                HStack {
                    WebImage(url: URL(string: model.seller!.avatar!))
                        .resizable()
                        .aspectRatio(contentMode: .fit)
                        .frame(width: 30, height: 30)
                        .clipShape(Circle())
                    
                    Text(model.seller!.nick_name!)
                        .font(.system(size: 10))
                        .lineLimit(1)
                        .foregroundColor(Color.black.opacity(0.5))
                    
                    Spacer()
                    
                    Image("goodscard_seller_zhima_good")
                        .resizable()
                        .aspectRatio(contentMode: .fit)
                        .frame(height: 20)
                }
                
            }
        }
    }
}
